package com.wu.d4_arrays;

import java.util.Arrays;
import java.util.Comparator;
import java.util.function.IntToDoubleFunction;

public class ArraysTest1 {
    

    public static void main(String[] args) {
        int[] arr={10,20,30,40,50,60,70,80,90};
        System.out.println(Arrays.toString(arr));

        double[] prices = {99.8,128,100};
        Arrays.setAll(prices, new IntToDoubleFunction() {
            @Override
            public double applyAsDouble(int value) {
                return prices[value]*0.8;
            }
        });
        System.out.println(Arrays.toString(prices));
        Arrays.sort(prices);
        System.out.println(Arrays.toString(prices));

        Student[] students = new Student[4];
        students[0] = new Student(16,"fds",151.1);
        students[1] = new Student(24,"fsd",158.2);
        students[2] = new Student(15,"fsdf",167.2);
        students[3] = new Student(55,"fsfs",197.4);

        Arrays.sort(students);
        System.out.println(Arrays.toString(students));

//       Arrays.sort(students, new Comparator<Student>() {
//            @Override
//            public int compare(Student o1, Student o2) {
////                if (o1.getAge() > o2.getAge()) {
////                    return 1;
////                }else if (o1.getAge() < o2.getAge()){
////                    return -1;
////                }
////                    return 0;
//              return Double.compare(o1.getHeight(),o2.getHeight());
//                }
//        });

//        Arrays.sort(students,(Student o1, Student o2) ->{
//                return Double.compare(o1.getHeight(),o2.getHeight());
//        });
//        Arrays.sort(students,(o1,o2) ->{
//            return Double.compare(o1.getHeight(),o2.getHeight());
//        });

//        Arrays.sort(students,(o1,o2) ->
//            CompareByData.compareByAge(o1,o2)
//        );

        Arrays.sort(students,(o1, o2) ->o1.getAge()-o2.getAge() );

        Arrays.sort(students ,CompareByData::compareByAge);

        Arrays.sort(students,(o1,o2) ->
                Double.compare(o1.getHeight(),o2.getHeight())
        );

        CompareByData compareByData = new CompareByData();
        Arrays.sort(students,compareByData::compareByAge2);



        System.out.println(Arrays.toString(students));

    }
}
